package com.wyg.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.wyg.service.AllUserService;
import com.wyg.service.ChangePwdService;
import com.wyg.service.LoginService;
import com.wyg.service.QuestionService;
import com.wyg.service.RegisteService;
import com.wyg.service.UpdateService;
import com.wyg.service.UserOperationService;

/**
 * Servlet implementation class Servlet
 */
@WebServlet("/Servlet")
public class Servlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Servlet() {
        super();
        System.out.println("servlet实例");
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(request,response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		
		String method = request.getParameter("method");
		System.out.println("方法————————"+method);
		
		switch (method) {
		case "registe":
			RegisteService rs = new RegisteService(request, response);
			rs.registe();
			break;
			
		case "login":
			LoginService ls = new LoginService(request, response);
			ls.login();
			break;

		case "allUser":
			AllUserService aus = new AllUserService(request, response);
			aus.queryAllUser();
			break;
		
		case "deleteStudent":
			UserOperationService uos = new UserOperationService(request, response);
			uos.deleteUser();
			break;
		//修改学员信息
		case "updateIt":
			UpdateService us = new UpdateService(request, response);
			us.queryUser();
			break;
		//修改页面修改(管理和用户)
		case "doChange":
			UpdateService uss = new UpdateService(request, response);
			uss.doChange();
			break;
		//重置密码
		case "initPwd":
			UpdateService use = new UpdateService(request, response);
			use.initPwd();
			break;
		//修改密码
		case "dochangePwd":
			ChangePwdService cpss = new ChangePwdService(request, response);
			cpss.doChange();
			break;
		//激活
		case "doactive":
			ChangePwdService cps = new ChangePwdService(request, response);
			cps.doActive();
			break;
		//精选试题
		case "partQuestions":
			QuestionService qs = new QuestionService(request, response);
			qs.showQuestion();
			break;
		//选择题1
		case "choice1":
			QuestionService qss = new QuestionService(request, response);
			qss.showChoiceQuestion();
			break;
		//判断题
		case "judge":
			QuestionService qts = new QuestionService(request, response);
			qts.showJudgeQuestion();
			break;
			
		//修改选择题跳转
		case "goChangeQuestion":
			QuestionService qsss = new QuestionService(request, response);
			qsss.goChangeQuestion();
			break;
		//修改选择
		case "changeQuestionInfo":
			QuestionService questions = new QuestionService(request, response);
			questions.changeQuestion();
			break;
		//手机号ajax
		default:
			RegisteService rss = new RegisteService(request, response);
			rss.phone();
			break;
		}

	}

}
